<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
    integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <script src="./js/vue.js"></script>
    <style>
        .wrapissue {
            background: rgb(194, 192, 192);
            padding: 10px;
        }
 
        .administration .aa {
            margin: 10px;
            background: rgb(153, 147, 147);
            width: 300px;
            padding: 10px;
        }
 
        .active {
            background: rgb(10, 96, 194);
            color: #fff;
        }
        .form-group{
            margin-top: 20px;
        }
        .wrapissue{
            width: 500px;
        }
    </style>
</head>
 
<body>
    <div id="app" class="container">
        <div class="form-group">
            <button type="button" class="btn" :class="isshow?'':'active'" @click="isshow=false">评论管理</button>
            <button type="button" class="btn" :class="isshow?'active':''" @click="isshow=true">发布评论</button>
        </div>
        <div class="wrapissue col-md-12" v-if="isshow">
            <div class="row form-group">
                <div class="col-md-4">
                    <input type="text" placeholder="昵称" v-model="name">
                </div>

            </div>
            <div class="row form-group">
                <div class="col-md-4">
                    <input type="text" placeholder="评论内容" v-model="content">
                </div>
                <div class="col-md-8"></div>
            </div>
 
            <div class="row form-group">
                <div class="col-md-4">
                    <button class="btn btn-info" @click="add()">立即提交</button>
                </div>
                <div class="col-md-8"></div>
            </div>
        </div>
 
        <div class="administration col-md-12" v-if="!isshow">
            <div v-for="item in arr" class="aa">
                <p>评论人：{{item.name}}</p>
                <p>评论时间：{{item.time}}</p>
                <p>评论内容：{{item.content}}</p>
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                isshow: true,
                arr: [],
                name: "",
                content: ""
            },
            methods: {
                add() {
                    if (this.name == "" && this.content == "") {
                        alert("昵称内容均不能为空");
                        return;
                    }
                    this.arr.push({
                        name: this.name,
                        content: this.content,
                        time: new Date().toLocaleDateString()
                    });
                    this.name = "";
                    this.content = "";
                }
            }
        })
    </script>

</body>